package com.ruoyi.web.controller.dev;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.demo.domain.Environmentdata;
import com.ruoyi.demo.service.IEnvironmentdataService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;

import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * devController
 * 
 * @author ruoyi
 * @date 2024-08-07
 */
@RestController
@RequestMapping("/demo/environmentdata")
public class EnvironmentdataController extends BaseController
{
    @Autowired
    private IEnvironmentdataService environmentdataService;

    /**
     * 查询dev列表
     */
    @PreAuthorize("@ss.hasPermi('demo:environmentdata:list')")
    @GetMapping("/list")
    public TableDataInfo list(Environmentdata environmentdata)
    {
        startPage();
        List<Environmentdata> list = environmentdataService.selectEnvironmentdataList(environmentdata);
        return getDataTable(list);
    }

    /**
     * 导出dev列表
     */
    @PreAuthorize("@ss.hasPermi('demo:environmentdata:export')")
    @Log(title = "dev", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Environmentdata environmentdata)
    {
        List<Environmentdata> list = environmentdataService.selectEnvironmentdataList(environmentdata);
        ExcelUtil<Environmentdata> util = new ExcelUtil<Environmentdata>(Environmentdata.class);
        util.exportExcel(response, list, "dev数据");
    }

    /**
     * 获取dev详细信息
     */
    @PreAuthorize("@ss.hasPermi('demo:environmentdata:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(environmentdataService.selectEnvironmentdataById(id));
    }

    /**
     * 新增dev
     */
    @PreAuthorize("@ss.hasPermi('demo:environmentdata:add')")
    @Log(title = "dev", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Environmentdata environmentdata)
    {
        return toAjax(environmentdataService.insertEnvironmentdata(environmentdata));
    }

    /**
     * 修改dev
     */
    @PreAuthorize("@ss.hasPermi('demo:environmentdata:edit')")
    @Log(title = "dev", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Environmentdata environmentdata)
    {
        return toAjax(environmentdataService.updateEnvironmentdata(environmentdata));
    }

    /**
     * 删除dev
     */
    @PreAuthorize("@ss.hasPermi('demo:environmentdata:remove')")
    @Log(title = "dev", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(environmentdataService.deleteEnvironmentdataByIds(ids));
    }
}
